package com.umakr.ax.app.service;

import com.umakr.ax.common.mapper.AreaMapper;
import com.umakr.ax.common.model.Area;
import com.umakr.ax.common.service.AreaService;
import com.umakr.ax.core.base.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 *
 * @author Mikey
 * @date 2017/12/30
 */
@Service
public class AppAreaService  extends BaseService<AreaMapper, Area> {
    @Autowired
    AreaService areaService;

    /**
     * 获取所有地区的树形表示
     * @return
     */
    public Object getAllAreasTree(){
        return areaService.selectList(null);
    }

    public Object listAreasByPid(Long pid){
        List<Map<String,Object>> list = baseMapper.listAreasByPid(pid);
        for(Map<String,Object> map : list){
            if(map.get("cityCode")==null){
                map.put("cityCode","");
            }

        }
        return resultMap(baseMapper.listAreasByPid(pid),1,"");
    }

}
